package com.ry.controller;

import com.ry.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author ry
 * @since 2021-11-10 20:40
 **/
@RequestMapping("/upload")
@RestController
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    /**
     * 上传图片
     * @param file  图片
     * @return  图片的映射地址
     */
    @PostMapping("/image")
    public String uploadImage(MultipartFile file){
        String resourceUrl = fileUploadService.uploadImage(file);

        return resourceUrl;
    }
}
